package com.whfc.ms.api.mach.service.impl;

import com.whfc.common.result.ListData;
import com.whfc.fuum.dto.AppCorpDTO;
import com.whfc.fuum.service.AppCorpService;
import com.whfc.fuum.service.SysDeptService;
import com.whfc.mach.dto.AppMachTypeDTO;
import com.whfc.mach.service.AppMachService;
import com.whfc.ms.api.mach.service.MsMachOptionService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author sun_guodong
 * @description
 * @date 2020-11-30
 */
@Service
public class MsMachOptionServiceImpl implements MsMachOptionService {

    @DubboReference(interfaceClass = AppCorpService.class, version = "1.0.0")
    private AppCorpService appCorpService;

    @DubboReference(interfaceClass = AppMachService.class, version = "1.0.0")
    private AppMachService appMachService;

    @DubboReference(interfaceClass = SysDeptService.class, version = "1.0.0")
    private SysDeptService sysDeptService;

    @Override
    public ListData<AppCorpDTO> corpList(Integer deptId) {
        List<AppCorpDTO> corpList = appCorpService.list(deptId);
        return new ListData<>(corpList);
    }

    @Override
    public ListData<AppMachTypeDTO> machTypeList(Integer deptId) {
        List<Integer> deptIds = sysDeptService.getDescendantDeptIdList(deptId);
        return appMachService.machTypeList(deptIds);
    }

}
